/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.swirrel.listener;

import java.awt.Component;
import java.lang.reflect.Method;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import org.swirrel.util.SwirrelException;
import org.swirrel.util.MethodCall;

/**
 *
 * @author Gronau
 */
public class SwirrelTreeSelectionListener extends AbstractSwirrelListener implements TreeSelectionListener {

    private final MethodCall valueChangedCall;

    public SwirrelTreeSelectionListener(MethodCall valueChangedCall) {
        this.valueChangedCall = valueChangedCall;
        if(! checkSignature(valueChangedCall, TreeSelectionEvent.class)) {
            throw new SwirrelException("Method must have none or one TreeSelectionEvent argument");
        }
    }

    public void valueChanged(TreeSelectionEvent e) {
        call(valueChangedCall, e);
    }
}
